home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / toolguid / dtksampl / convertâ–¡r.sx next >
Encoding:
Text File  |  1996-05-21  |  2.6 KB  |  89 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Filename:
  3. --       converter.sx
  4.  
  5. -- Purpose:
  6. --     This file imports a Director title, and prints information
  7. --    about the cast to a file called castData.txt in theScriptDir
  8. --     and information about the score to a file called scorData.txt.
  9.  
  10.  
  11. -- Specialized Classes:
  12. --      This file uses classes defined in the files myCtrans.sx 
  13. --    and myStrans.sx
  14.  
  15. -- Instructions to User:
  16. --      Make sure myCtrans.sx and myStrans.sx live in the
  17. --     same folder as this file.
  18. --    Load this file. When the "Choose File" dialog box appears,
  19. --    choose a Director file to import.
  20. --    When the importing is finished, look in the files
  21. --    castData.sxt and scorData.sxt for information
  22. --    about the cast and score.
  23.  
  24. -- Author:
  25. --      Jocelyn Becker
  26. ---------------------------------------------------------------
  27. ---------------------------------------------------------------
  28.  
  29. -- load the DTK
  30. open TitleContainer dir:theStartDir path:"utils/dtk/dtk.sxt"
  31.  
  32. -- Create a module to work in
  33. module myModule
  34.     uses DTK
  35.     uses ScriptX
  36. end
  37.  
  38. in module myModule
  39.  
  40. fileIn theScriptdir name:"myCtrans.sx"
  41. fileIn theScriptdir name:"myStrans.sx"
  42.  
  43. -- make sure we are still in myModule
  44. in module myModule
  45.  
  46. -- Create a new DTK instance
  47. -- use the open file dialog box to allow the user to select a Director file
  48. global locPanel := new OpenPanel
  49. openFilePanel locPanel
  50. dirFile := locPanel.filename
  51.  
  52. -- create an instance of DTK
  53. myDTK := new DTK directorFileName:dirFile
  54.  
  55. -- if the files castData.txt and scoreData.txt already exist
  56. -- then delete them
  57. if isfile theScriptDir "castData.txt" do delete theScriptDir "castData.txt"
  58. if isfile theScriptDir "scoreData.txt" do delete theScriptDir "scorData.txt"
  59.  
  60. -- create the files castData.txt and scoreData.txt
  61. createFile theScriptDir "castData.txt" @text
  62. createFile theScriptDir "scoreData.txt" @text
  63.  
  64. -- Create the output streams for the translators
  65. global castStream := getStream theScriptDir "castData.txt" @readwrite
  66. global scoreStream := getStream theScriptDir "scoreData.txt" @readwrite
  67.  
  68. -- Create a cast and score translator
  69. global myst := new ScoreToInfoTranslator outputstream:scoreStream
  70. global myct := new CastToInfoTranslator outputstream:castStream
  71.  
  72. -- tell the cast translator what classes to use when translating 
  73. -- shapes, bitmaps, text, and video
  74. myct.shapeClass := CastTwoDShape
  75. myct.textClass := CastTextPresenter
  76. myct.bitmapClass := CastTwoDShape
  77. myct.videoClass := CastMoviePlayer
  78.  
  79. -- Associate the Cast Translator with the DTK instance.
  80. -- Associate the Score Translator with the DTK instance.
  81.  
  82. myDTK.castTranslator := myct
  83. myDTK.scoreTranslator := myst
  84.  
  85. -- Set the DTK to work to import the data:
  86. translateDirector myDTK
  87.  
  88. -->>>
  89.